package com.jeeplus.test.tools.resp;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.io.Serializable;

@ApiModel("分页请求参数")
public class ZyPageRequest implements Serializable {
    private static final Integer PAGE_NO = 1;
    private static final Integer PAGE_SIZE = 10;
    @ApiModelProperty(
            value = "页码，从 1 开始",
            required = true,
            example = "1"
    )
    private @NotNull(
            message = "页码不能为空"
    ) @Min(
            value = 1L,
            message = "页码最小值为 1"
    ) int pageNo;
    @ApiModelProperty(
            value = "每页条数，最大值为 100",
            required = true,
            example = "10"
    )
    private @NotNull(
            message = "每页条数不能为空"
    ) @Min(
            value = 1L,
            message = "页码最小值为 1"
    ) @Max(
            value = 100L,
            message = "页码最大值为 100"
    ) int pageSize;

    public ZyPageRequest() {
        this.pageNo = PAGE_NO;
        this.pageSize = PAGE_SIZE;
    }

    public @NotNull(
            message = "页码不能为空"
    ) int getPageNo() {
        return this.pageNo;
    }

    public @NotNull(
            message = "每页条数不能为空"
    ) int getPageSize() {
        return this.pageSize;
    }

    public void setPageNo(@NotNull(
            message = "页码不能为空"
    ) int pageNo) {
        this.pageNo = pageNo;
    }

    public void setPageSize(@NotNull(
            message = "每页条数不能为空"
    ) int pageSize) {
        this.pageSize = pageSize;
    }

    public boolean equals(Object o) {
        if (o == this) {
            return true;
        } else if (!(o instanceof ZyPageRequest)) {
            return false;
        } else {
            ZyPageRequest other = (ZyPageRequest)o;
            if (!other.canEqual(this)) {
                return false;
            } else if (this.getPageNo() != other.getPageNo()) {
                return false;
            } else {
                return this.getPageSize() == other.getPageSize();
            }
        }
    }

    protected boolean canEqual(Object other) {
        return other instanceof ZyPageRequest;
    }

    public int hashCode() {
        boolean PRIME = true;
        int result = 1;
        result = result * 59 + this.getPageNo();
        result = result * 59 + this.getPageSize();
        return result;
    }

    public String toString() {
        int var10000 = this.getPageNo();
        return "ShunPageRequest(pageNo=" + var10000 + ", pageSize=" + this.getPageSize() + ")";
    }
}
